<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Canvas</title>
    <style type="text/css">
        body {
            text-align: center;
            padding-top: 20px;
        }
        canvas {
            box-shadow: 0 0 10px #333;
            margin: 0 auto;
        }
    </style>
</head>
<body onload="draw()">
<canvas id="canvas" width="800" height="600">
    你的浏览器太 low 了，请更新~!
</canvas>

<script>
    function draw() {
        var canvas = document.getElementById("canvas");
        if (canvas.getContext) {
            var ctx = canvas.getContext('2d');

            for (var i = 0; i < 4; i ++) {
                for (var j = 0; j < 3; j ++) {
                    ctx.beginPath();
                    var x = 25 + j * 50;
                    var y = 25 + i * 50;
                    var radius = 20;
                    var startAngle = 0;
                    var endAngle = Math.PI + (Math.PI * j) / 2;

                    var anticlockwise = (i % 2 != 0);

                    ctx.arc(x, y, radius, startAngle, endAngle, anticlockwise);

                    if (i < 2) {
                        ctx.stroke();
                    } else {
                        ctx.fill();
                    }
                }
            }
        }
    }
</script>
</body>
</html>
